<%@ page language="java" contentType="text/html;charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-gdc.tld" prefix="gdc"%>

<html:html>
<head>
	<title>查看权限成员</title>
	<link rel="stylesheet" href="././css/public.css">
</head>

<script type="text/javascript" src="./js/prototype-1.4.0.js"></script>
<script type="text/javascript" src="./js/scriptaculous.js"></script>
<script type="text/javascript" src="./js/overlibmws.js"></script>
<script type="text/javascript" src="./js/ajaxtags.js"></script>

<script language="JavaScript">

	function r_del() {
		var msg = "您真的确定要删除吗？\n\n请确认！";
		if (confirm(msg)==true){
			if(isselect()){
				document.forms[0].action = "delroleEmployeeAction.do?roleno=<bean:write name='roleno' />";	
		    	document.forms[0].submit();
				return true;
			}else{
				alert("请选择要删除的选项！");
				return false;
			}    
		}else {
			return false;
		}
	}

	function isselect() {
		var  a  =  document.roleEmployeeForm("employeenos");
     	for  (var  i=0;  i<a.length;  i++){  
     	    if(a[i].checked  ==  false){
     	    }else if(a[i].checked  ==  true){
     	    	return true;
     	    }
     	}
     	return false;
	}

	function  checkbox_selectAll(me){  
     	var  items =  document.roleEmployeeForm("employeenos");  
     	for  (var  i=0;  i<items.length;  i++){  
     	    items[i].checked  =  me.checked;  
     	}  
	} 

	function back() 	{
		document.location.href='roleManageSearch.do?isReturn=NO';
	}
	
	function select_account_dialog(){
		var selected_empno = document.getElementById('selected_empno').value;
		var url = 'accountSelectDialog.do';
        var value=window.showModalDialog(url,"obj","dialogWidth=580px;dialogHeight=600px;Status=no;");
        //value 对话框的返回值是个一维数组：0客户ID,1客户代码-简称
        if(value!=undefined && value!="" && value.indexOf(',')!=-1){
        	var vauleArray = value.split(',');
        	var accountno = vauleArray[0];
			r_add(accountno);
        }       
	}

	function r_add(accountno) {
		var roleno = '<bean:write name="roleno" />' ;
		var url = 'addroleEmployeeAction.do?roleno='+ roleno +'&accountno='+accountno;	
		document.location.href = url;
	}

	
</script>

<body> 
<br>
<form name="roleEmployeeForm" Method="post" action="delroleEmployeeAction.do" >
 		<input type="hidden" value='<bean:write name="roleno"/>' name="roleno">
 		<input type="hidden" id="selected_empno" name="selected_empno" value="<bean:write name="selected_empno"/>" Class="inputline"/>
		<table width="98%" cellpadding="0" cellspacing="0" align="center">
			<tr>
				<td valign="top">
					<strong><font color="#040466">&nbsp;&nbsp;权限管理 -->&nbsp;&nbsp;权限成员</font></strong>
					<hr noshade width="100%" size="1">
					<div align="center"><strong><font color="#040466" ><bean:write name="rolename" /></font></strong></div>
					<input name="Submit" type="button" class="button" value=" 返 回 " onClick="back();">
					<input type="button" value=" 删 除 " name="Submit" class="button" onClick="r_del();">  
					<input type="button" value=" 添 加 " name="Submit" class="button" onClick="select_account_dialog();r_add();"><br>
					
					<table width="100%" border="1" id="results_table_1" style="display:block" align="center" cellpadding="2" cellspacing="0" borderColor="silver" class="datatable">
						<tr bgcolor="#F3F3F3" align="center">
							<td width="2%" align="center">
								<input type="checkbox"  value="-1" onclick="checkbox_selectAll(this)">
							</td>
							<td width="2%" align="center">
								序号
							</td>
							<td width="7%" align="center">
								帐号
							</td>
							<td width="7%" align="center">
								姓名
							</td>
							<td width="12%" align="center">
								邮箱
							</td>
							<td width="8%" align="center">
								固定电话
							</td>
							<td width="8%" align="center">
								移动电话
							</td>
							<td width="5%" align="center">
								是否锁定
							</td>
						</tr> 
						 
						<logic:notEmpty name="results">
						
						<logic:iterate id="item" name="results" indexId="index">

							<tr onMouseOut="this.style.backgroundColor='#FFFFFF'" onMouseOver="this.style.backgroundColor='#DDDDDD'">
								<td align="center"> 
									<input type="checkbox" value='<bean:write name="item" property="accountno" />' name="employeenos"> 
								</td>
								<td align="center">
									<gdc:iteratorNO indexId="index" />
								</td>
								<td align="center">
									<bean:write name="item" property="username" /> 
								</td>
								<td align="center">
									<bean:write name="item" property="name" />
								</td>
								<td align="center">
									<bean:write name="item" property="email" />
								</td>
								<td align="center">
									<bean:write name="item" property="telephone" />
								</td>
								<td align="center">
									<bean:write name="item" property="mobilephone" />
								</td>
								<td align="center">
									<bean:write name="item" property="islock"/>
								</td>
							</tr>
							
						</logic:iterate>
						</logic:notEmpty>

					</table>
					<input name="Submit" type="button" class="button" value=" 返 回 " onClick="back();"> 
					<input type="button" value=" 删 除 " name="Submit" class="button" onClick="r_del();"> 
					<input type="button" value=" 添 加 " name="Submit" class="button" onClick="select_account_dialog();">
				</td>
			</tr>
		</table>

</form>


<html:errors />
<gdc:errors />

</body>
</html:html>
